import './assets/main.css'
import config from './config'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
// import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/src/index.scss'
import microApp from '@micro-zoe/micro-app';
import { jobType as jobTypeArr } from '@/assets/js/dictData'
import store from '../store'
window.jobTypeArr = jobTypeArr
microApp.start(
    {
        'disable-memory-router': true,// 禁用虚拟路由
        // globalAssets: {
        //     css: [

        //     ],
        //     js: [

        //     ]
        // },
        preFetchApps: [
            {
                name: 'childHome',
                url: `${config.nuxt2}/childHome/`,
                level: 3
            },
            {
                name: 'childJob',
                url: `${config.vue2}`,
                level: 2
            },
            {
                name: 'childEnterprise',
                url: `${config.vue2}/child/findEnterprise/`,
                level: 3,
                iframe: true
            },
            {
                name: 'childAbout',
                url: `${config.vue2}`,
                level: 3
            }
        ],// 预加载的子应用
        lifeCycles: {
            // 全局的生命周期钩子
            created() {
                console.log('基座app created');
            },
            beforemount() {
                console.log('基座app beforemount');
            },
            mounted() {
                console.log('基座app mounted');
                const loading = document.querySelector('#appLoading')
                console.log(loading, '在基座监听子应用loading')
            },
            unmount() {
                console.log('基座app unmount');
            },
            error() {
                console.log('基座app error');
            }
        }
    }
)
// microApp.preFetch(apps: app[] | () => app[], delay?: number)// 预加载子应用

microApp.router.setBaseAppRouter(router)// 注册基座路由
const app = createApp(App)
app.use(router)
app.use(ElementPlus)
app.use(store)
app.mount('#app')
